home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2007 January
/
PCWorld_2007-01_cd.bin
/
v cisle
/
autoit
/
autoit-v3.2.0.1-setup.exe
/
Examples
/
Helpfile
/
ObjEvent.au3
< prev
next >
Wrap
Text File
|
2006-06-28
|
2KB
|
56 lines
; ObjEvent example
$oIE=ObjCreate("InternetExplorer.Application.1") ; Create Internet Explorer application
$SinkObject=ObjEvent($oIE,"IEEvent_","DWebBrowserEvents2") ; Assign events to UDFs starting with IEEvent_
; Do some browsing activities
$oIE.Visible=1
$oIE.RegisterAsDropTarget = 1
$oIE.RegisterAsBrowser = 1
$oIE.Navigate( "http://www.AutoItScript.com/" )
sleep(3000) ; Give it time to load the web page
$SinkObject=0 ; Stop IE Events
$oIE.Quit ; Quit IE
$oIE=0
exit
; one of many Internet Explorer Event Functions
Func IEEvent_ProgressChange($Progress,$ProgressMax)
ProgressSet ( ($Progress * 100) / $ProgressMax , ($Progress * 100) / $ProgressMax & " percent to go." , "loading web page" )
EndFunc
Exit
; COM Error Handler example
; -------------------------
$oIE=ObjCreate("InternetExplorer.Application.1") ; Create Internet Explorer application
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Initialize a COM error handler
$oIE.UnknownMethod ; Deliberately call an undefined method
If @error then
Msgbox (0,"AutoItCOM test","Test passed: We got an error number: " & @error)
Else
Msgbox (0,"AutoItCOM test","Test failed!")
Endif
Exit
; This is my custom defined error handler
Func MyErrFunc()
$HexNumber=hex($oMyError.number,8) ; for displaying purposes
Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _
"err.description is: " & @TAB & $oMyError.description & @CRLF & _
"err.number is: " & @TAB & $HexNumber & @CRLF & _
"err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF _
)
SetError(1) ; to check for after this function returns
Endfunc